package easy

func TemperatureTrend(temperatureA []int, temperatureB []int) int {
	m := len(temperatureA)
	count := 0
	ans := 0
	arrA := make([]int, m)
	arrB := make([]int, m)
	for i := 1; i < m; i++ {
		arrA[i-1] = getTrend(temperatureA[i], temperatureA[i-1])
		arrB[i-1] = getTrend(temperatureB[i], temperatureB[i-1])
		if arrA[i-1] == arrB[i-1] {
			count++
			ans = max(ans, count)
		} else {
			count = 0
		}
	}
	return ans
}

func getTrend(x, y int) int {
	temp := 0
	if x > y {
		temp = 1
	} else if x < y {
		temp = -1
	}
	return temp
}
